package me.muci.thread02_executor;

import org.junit.Test;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * ClassName: CachedThreadPoolTest
 * Description: 一个任务创建一个线程
 * date: 2022/2/23 9:24
 *
 * @author muci
 * @since JDK 1.8
 */
public class CachedThreadPoolTest {
    @Test
    public void create() throws InterruptedException {
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 10; i++) {
            executorService.execute(new MyRunnable());
        }
        executorService.wait(100);
        executorService.shutdown();
    }
}
